package com.yvon.service.demo.spring.context.event;

import com.yvon.service.demo.spring.beans.factory.BeanFactory;
import com.yvon.service.demo.spring.context.ApplicationEvent;
import com.yvon.service.demo.spring.context.ApplicationListener;

/**
 * 简单应用程序事件多播
 *
 * @author Yvon
 * @since 2022-12-29
 */
public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster{

    public SimpleApplicationEventMulticaster(BeanFactory beanFactory) {
        setBeanFactory(beanFactory);
    }

    @SuppressWarnings("unchecked")
    @Override
    public void multicastEvent(final ApplicationEvent event) {
        for (final ApplicationListener listener : getApplicationListeners(event)){
            listener.onApplicationEvent(event);
        }
    }
}
